package com.blogspot.wanyancan.server;

import java.util.Date;
import com.blogspot.wanyancan.client.ShowRespService;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class ShowRespServiceImpl extends RemoteServiceServlet implements
		ShowRespService {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public String displayResponse(String req) {
		if (req.length() < 1) {
			throw new IllegalArgumentException(
					"Blank submissions from the client are invalid.");
		}
		StringBuffer buf = new StringBuffer("Your submission: ");
		Date date = new Date();
		String serverInfo = this.getServletContext().getServerInfo();
		
		buf.append(req);
		buf.append("\n");
		buf.append("Server response: ");
		buf.append(date.toString());
		buf.append("\n");
		buf.append(serverInfo);
		return buf.toString();
	}
}